<?php

    header('content-type:text/html;charset=utf-8') ;
    header("Access-Control-Allow-Origin:*");

    
<<<<<<< HEAD

    $host = 'b-k5hmuwuw4s0vsb.bch.rds.gz.baidubce.com:3306';
    $name = 'b_k5hmuwuw4s0vsb';
    $pwd = 'czm061002';
    $dbname = 'b_k5hmuwuw4s0vsb';
    $conn = mysqli_connect("b-k5hmuwuw4s0vsb.bch.rds.gz.baidubce.com","b_k5hmuwuw4s0vsb","czm061002","b_k5hmuwuw4s0vsb") ;
=======
    $host = 'localhost';
    $name = 'root';
    $pwd = 'root';
    $dbname = '123';
    $conn = mysqli_connect($host , $name , $pwd , $dbname);

>>>>>>> c2a0b16d374b2dadbf60483b2ca7e378d937a164
    if(!$conn) {
        die('数据库连接失败');
    }

    //根据用户名与商品ID  删除

    $uname = $_POST['phone'];
    $id = $_POST['id'];

    $obj = [];

    if($uname && $id) {
        $sql = "delete from cart where phone = '$uname' and goods_id = $id";
        mysqli_query($conn , $sql);
        $rows = mysqli_affected_rows($conn);
        if($rows > 0) {
            $obj['status'] = true;
            $obj['msg'] = '删除成功';
        } else {
            $obj['status'] = false;
            $obj['msg'] = '';
        }，
    } else {
        $obj['status'] = false;
        $obj['msg'] = '前端数据有误';
    }

    echo(json_encode($obj , JSON_UNESCAPED_UNICODE));